Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

how to get the history of an work item?

Hi,

Does anybody know how to get the history of an work item? By history, I mean changes to a given work item. I tried IAuditable.getPredecessorState on an IWorkItem, but when I attempted to get the fields of the predecessor state, I got an IllegalStateException. The error message says "Attempting to get unset feature: InternalState". It's clear that I'm not doing things right, but I have no idea how I should do it correctly. Please help! Thanks!

Annie

1

0 votes


Accepted answer

Permanent link
You probably fetched the work item with only part of its properties, you can use IItemManager.fetchCompleteState() to get the full item in its historical state. If you want to get the full history you can also get all state handles at once using IItemManager.fetchAllStateHandles() instead of walking the history using IAuditable.getPredecessorState().

Regards,

Christof
Jazz Work Item team
Ralph Schoon selected this answer as the correct answer

0 votes


6 other answers

Permanent link
Thanks Christof! What you suggested worked great!

I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)

Thanks!
Annie

0 votes

Comments

Hi Annie

I am trying to do the same thing i.e. fetch the previous states the work itemsusing  IItemManager.fetchAllStateHandles() and I am getting the number of instances equal to the number of the times work item saved. However , I can not fetch the work item states of each instance.

Could you please help on this.


Permanent link
You can use IItem.modified() (which returns a Date instead of a Timestamp).

Regards,

Christof
Jazz Work Item team

0 votes


Permanent link
I am using RTC version 3.0, and accessing JAVA api.

I am facing the following problem while trying to fetch the enumerations:

Code snippet:
IEnumeration<IPriority> enums = (IEnumeration<IPriority>)workItemClient.resolveEnumeration(attribute, null);


Also, the same error occurs, while doing following operation:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", new SysoutProgressMonitor());



Exception in thread "main" java.lang.IllegalArgumentException
at com.ibm.team.process.internal.common.util.AbstractProcess.computeConfigurationData(AbstractProcess.java:328)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:313)
at com.ibm.team.process.internal.common.util.AbstractProcess.getProjectConfigurationData(AbstractProcess.java:299)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:68)
at com.ibm.team.workitem.common.internal.EnumerationManager$InternalEnumerations.resolve(EnumerationManager.java:52)
at com.ibm.team.workitem.common.internal.EnumerationManager.updateCache(EnumerationManager.java:198)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:117)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:74)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
at com.ibm.team.workitem.common.internal.EnumerationManager.internalResolve(EnumerationManager.java:173)
at com.ibm.team.workitem.common.internal.EnumerationManager.resolve(EnumerationManager.java:169)
at com.ibm.team.workitem.common.internal.WorkItemCommon.resolveEnumeration(WorkItemCommon.java:453)
at CreateWorkItem.main(CreateWorkItem.java:147)

0 votes


Permanent link
Hello Christof,

I recently went through this post while trying to search any article that explains on reporting out of the history details. This post seems something similar. I would like to start writing reports that can fetch the changes of a work item along with the state changes. Could you please if there is a way I can achieve this, if so how?

Many Thanks,
Regards,
Sunita

Thanks Christof! What you suggested worked great!

I have another question now. In addition to the previous states of the work item, I'm interested in *when* a given state was created. I did find a method "getModifiedBy" in the IWorkItem interface which tells me *who* created a state, but I wanted to know *when*. When I used the debugger to examine the state, I saw a field called "modified" which is the timestamp in the work item object, but this field is not exposed by the API. Is there a way to get this information from the API? (Apparently, I just couldn't even do a hack to cast the state to a WorkItemImpl, which defines the "modified" field of Timestamp type.)

Thanks!
Annie

0 votes


Permanent link
We would fetch the user id from the predecessor state of a work-item.
We are using the code below:
ITeamRepository repo = ...
IWorkItem wi = ...
IAuditable predecessorState = repo.itemManager().fetchCompleteState(wi.getPredecessorState(), null);
IContributorHandle contributorH = predecessorState.getModifiedBy();
IContributor contributor = (IContributor) repo.itemManager().fetchCompleteItem(contributorH, IItemManager.DEFAULT, null);
String userId = contributor.getUserId());
But the userId is coming from the last contributor who changed the work-item's state, not from the predeccessor... Any advice?
Thanks in advance.

0 votes


Permanent link

 can you share the snippet for the same so that it will helpful for others also.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Jul 22 '08, 5:32 p.m.

Question was seen: 12,585 times

Last updated: Mar 08 '17, 7:48 a.m.

Confirmation Cancel Confirm